<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../../_template.xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://xmlns.jcp.org/jsf/core">

    <ui:define name="centro">
        <h:form>
            <p:messages />
            <p:outputLabel value="Fluxo de Caixa - Consultar Documento" style="font-size: x-large; width: 92%; margin-left: 25px" 
                           styleClass="labelInserir" />
            <p:fieldset styleClass="fieldsetInsert" style="width: 92%; margin-left: 25px">
                <h:panelGrid columns="5" style="margin-bottom: 10px" >
                    <h:panelGrid columns="1" >
                        <p:outputLabel style="margin-left: 25px; text-align: left" value="Conta" />
                        <p:selectOneMenu value="#{fluxoCaixaBean.documento.conta}" converter="entityConverter"
                                         style="margin-left: 25px" disabled="true">
                                <f:selectItem itemLabel="selecione" noSelectionOption="true" />
                                <f:selectItems value="#{contaBean.contas}" var="conta" itemLabel="#{conta.nome}"/>
                        </p:selectOneMenu>
                    </h:panelGrid>
                    
                    <h:panelGrid columns="1" >
                        <p:outputLabel style="margin-left: 20px; text-align: left" value="Tipo de Documento" />
                        <p:selectOneMenu value="#{fluxoCaixaBean.documento.tipoDocumento}" converter="entityConverter" disabled="true" >
                                         style="margin-left: 20px">
                            <f:selectItem itemLabel="selecione"/>                            
                        </p:selectOneMenu>
                    </h:panelGrid>
                    
                    <h:panelGrid columns="1" style="margin-bottom: 5px" cellpadding="5" >
                        <p:outputLabel style="margin-left: 20px; text-align: left" value="Natureza" />
                        <p:selectOneRadio value="#{fluxoCaixaBean.documento.natureza}" style="margin-left: 20px" disabled="true">
                            <f:selectItem itemLabel="Débito"  itemValue="DEBITO" />
                            <f:selectItem itemLabel="Crédito" itemValue="CREDITO"/>                            
                        </p:selectOneRadio> 
                    </h:panelGrid>
                    
                    <h:panelGrid columns="1" >
                        <p:outputLabel style="margin-left: 20px; text-align: left" value="Custo" />
                        <p:selectOneMenu id="tipoCusto" value="#{fluxoCaixaBean.documento.tipoCusto}" 
                                         style="margin-left: 20px" disabled="true">
                            <f:selectItem itemLabel="selecione"/>
                        </p:selectOneMenu>
                    </h:panelGrid>
                    
                    <h:panelGrid columns="1" >
                        <p:outputLabel style="margin-left: 20px; text-align: left" value="Grupo de Lançamento" />
                        <p:selectOneMenu value="#{fluxoCaixaBean.documento.grupoLancamento}" converter="entityConverter" disabled="true"
                                         style="margin-left: 20px; width: 200px" >
                            <f:selectItem itemLabel="selecione"/>
                            <f:selectItems value="#{grupoLancamentoBean.grupoLancamentos}" var="grupo" itemLabel="#{grupo.descricao}"/>
                        </p:selectOneMenu>
                    </h:panelGrid>
                    
                </h:panelGrid>
                <h:panelGrid columns="4" style="margin-bottom: 10px">
                    <h:panelGrid columns="1" >
                        <p:outputLabel style="margin-left: 25px; text-align: left" value="Número" />
                        <p:inputText size="2" value="#{fluxoCaixaBean.documento.nrDocumento}" 
                                     style="width: 100px; margin-left: 25px;text-align: right" disabled="true" />
                    </h:panelGrid>
                    
                    <h:panelGrid columns="1" >
                        <p:outputLabel style="margin-left: 30px; text-align: left" value="Data da Emissão" />
                        <p:calendar pattern="dd/MM/yyyy" yearRange="c-100:c+100" navigator="true" readonlyInput="true"
                                    value="#{fluxoCaixaBean.documento.dataEmissao}" disabled="true"/> 
                    </h:panelGrid>
                    
                    <h:panelGrid columns="1" >
                        <p:outputLabel style="margin-left: 30px; text-align: left" value="Origem/Destino" />
                        <p:selectOneMenu id="origem" value="#{fluxoCaixaBean.documento.origem}" style="margin-left: 30px; width: 150px"
                                         disabled="true" >
                            <f:selectItem itemLabel="selecione"/>
                        </p:selectOneMenu>
                    </h:panelGrid>
                    
                    <h:panelGrid columns="1" >
                        <p:outputLabel style="margin-left: 30px; text-align: left" value="Nome" />
                        <p:selectOneMenu id="nomes" value="#{fluxoCaixaBean.documento.pessoa}" converter="entityConverter" 
                                         style="margin-left: 30px; width: 350px" 
                                         disabled="true">
                            <f:selectItem itemLabel="selecione"/>
                        </p:selectOneMenu>
                    </h:panelGrid>
                </h:panelGrid>   
                <h:panelGrid columns="2" style="margin-bottom: 10px" >
                    <h:panelGrid columns="1" >
                        <p:outputLabel style="margin-left: 25px; text-align: left" value="Valor" />
                        <p:inputText size="20" value="#{fluxoCaixaBean.documento.valor}" 
                                     style="margin-left: 25px; width: 150px ;text-align: right" styleClass="moeda"
                                     disabled="true"> 
                            <f:convertNumber minFractionDigits="2" maxFractionDigits="2" locale="pt_BR" />
                        </p:inputText>
                    </h:panelGrid>
                    
                    <h:panelGrid columns="1" >
                        <p:outputLabel style="margin-left: 30px; text-align: left" value="Forma de Pagamento" />
                        <p:selectOneMenu value="#{fluxoCaixaBean.documento.formaPagamento}" style="margin-left: 30px"
                                         disabled="true" >
                            <f:selectItem itemLabel="selecione"/>
                            <f:selectItem itemLabel="À vista"   itemValue="A_VISTA"  />
                            <f:selectItem itemLabel="Parcelado" itemValue="PARCELADO"/>
                        </p:selectOneMenu>
                    </h:panelGrid>
                </h:panelGrid>
                <h:panelGrid id="p1" columns="4" style="margin-bottom: 10px" >
                    <h:panelGrid id="p11" columns="1" >
                        <p:outputLabel id="l1" style="margin-left: 25px; text-align: left" value="Qtde Parcelas" />
                        <p:inputText id="qtdeParcelas" type="number" size="5" value="#{fluxoCaixaoBean.documento.qtdeParcelas}" 
                                     disabled="true" style="margin-left: 25px; text-align: right; width: 100px"
                                     required="true" requiredMessage="Informe a quantidade de parcelas"  />
                    </h:panelGrid>
                    <h:panelGrid id="p12" columns="1" >
                        <p:outputLabel id="l2" style="margin-left: 30px; text-align: left" value="Periodicidade" />
                        <p:selectOneMenu id="periodicidade" value="#{fluxoCaixaBean.documento.periodicidade}" 
                                         disabled="true" style="margin-left: 30px" >
                            <f:selectItem itemLabel="selecione"/>
                        </p:selectOneMenu>
                    </h:panelGrid>
                    <h:panelGrid id="p13" columns="1" >
                        <p:outputLabel id="l3" style="margin-left: 30px; text-align: left" value="Valor de Entrada" />
                        <p:inputText id="entrada" value="#{fluxoCaixaBean.documento.valorEntrada}"
                                     style="margin-left: 30px; text-align: right; width: 150px" styleClass="moeda"
                                     disabled="true" >
                            <f:convertNumber minFractionDigits="2" maxFractionDigits="2" locale="pt_BR" />
                        </p:inputText>
                    </h:panelGrid>
                    <h:panelGrid id="p14" columns="1" >
                        <p:outputLabel id="l4" style="margin-left: 30px; text-align: left" value="Data da Primeira Parcela" />
                        <p:calendar id="dtPrimeiraParcela" pattern="dd/MM/yyyy" yearRange="c-100:c+100" navigator="true" readonlyInput="true"
                                    value="#{fluxoCaixa.documento.dataPrimeiraParcela}" disabled="true"
                                    style="margin-left: 30px" />
                    </h:panelGrid>
                </h:panelGrid>
                <br/>
            </p:fieldset>
 
            <p:fieldset styleClass="fieldsetInsert" style="width: 92%; margin-left: 25px">
                <h:panelGrid  style="margin-top: 30px" >
                    <p:dataTable value="#{fluxoCaixaBean.documento.lancamentos}" var="lcto"
                                 style="margin-left: 10px; margin-bottom: 20px" >
                        <p:column style="width: 10px" headerText="Número do Lançamento"  >
                            <h:outputText value="#{lcto.sequencial}" />
                        </p:column>
                        <p:column style="width: 10px" headerText="Data de Pagamento" >
                            <h:outputText value="#{lcto.dataPagamento}">
                                <f:convertDateTime pattern="dd/MM/yyyy" />
                            </h:outputText>
                        </p:column>
                        <p:column style="width: 10px" headerText="Valor" >
                            <h:outputText value="#{lcto.valor}" styleClass="moeda">
                                <f:convertNumber minFractionDigits="2" maxFractionDigits="2" locale="pt_BR" />
                            </h:outputText>
                        </p:column>
                        <p:column style="width: 10px" headerText="Situação" >
                            <h:outputText value="#{lcto.situacao}"/>
                        </p:column>
                    </p:dataTable>
                </h:panelGrid>
                <br/>
                <br/>
                <p:commandButton value="Voltar" action='fluxoCaixa' immediate="true" ajax="false" 
                                 style="margin-left: 10px; margin-bottom: 10px" />
           </p:fieldset> 
        </h:form>
    </ui:define>
</ui:composition>
